/*
 * Copyright (C) 2004, Velocityme Partnership
 * SystemPropertyActionForm.java
 *
 * Created on 28 October 2004, 08:56
 */

package com.velocityme.www.actionforms;

import com.velocityme.valueobjects.SystemPropertyValue;
import java.io.Serializable;
import java.util.*;
import org.apache.struts.action.*;

/**
 *
 * @author  Robert Crida Work
 */
public class SystemPropertyActionForm extends ActionForm {
    
    public class SystemProperty implements Serializable {
        private Integer m_systemPropertyId;
        private String m_name;
        private String m_value;
        private boolean m_isPrivate;
        private boolean m_isEditable;
        
        public Integer getSystemPropertyId() { return m_systemPropertyId; }
        public void setSystemPropertyId(Integer systemPropertyId) { m_systemPropertyId = systemPropertyId; }
        public String getName() { return m_name; }
        public void setName(String name) { m_name = name; }
        public String getValue() { return m_value; }
        public void setValue(String value) { m_value = value; }
        public boolean getIsPrivate() { return m_isPrivate; }
        public void setIsPrivate(boolean isPrivate) { m_isPrivate = isPrivate; }
        public boolean getIsEditable() { return m_isEditable; }
        public void setIsEditable(boolean isEditable) { m_isEditable = isEditable; }
    }
    
    private ArrayList m_systemPropertyList;
    
    /** Creates a new instance of SystemPropertyActionForm */
    public SystemPropertyActionForm() {
        m_systemPropertyList = new ArrayList();
    }
    
    public void reset(ActionMapping mapping, javax.servlet.http.HttpServletRequest request) {
        Iterator i = m_systemPropertyList.iterator();
        while(i.hasNext()) {
            SystemProperty systemProperty = (SystemProperty)i.next();
            systemProperty.setIsPrivate(false);
        }
    }
    
    public void setSystemPropertyValues(Collection systemPropertyValues) {
        m_systemPropertyList.clear();
        Iterator i = systemPropertyValues.iterator();
        while(i.hasNext()) {
            SystemPropertyValue systemPropertyValue = (SystemPropertyValue)i.next();
            SystemProperty systemProperty = new SystemProperty();
            systemProperty.m_systemPropertyId = systemPropertyValue.getSystemPropertyId();
            systemProperty.m_name = systemPropertyValue.getName();
            systemProperty.m_value = systemPropertyValue.getValue();
            systemProperty.m_isPrivate = systemPropertyValue.getIsPrivate();
            systemProperty.m_isEditable = systemPropertyValue.getIsEditable();
            m_systemPropertyList.add(systemProperty);
        }
    }
    
    public Collection getSystemPropertyValues() {
        Collection propertyValues = new ArrayList();
        Iterator i = m_systemPropertyList.iterator();
        while(i.hasNext()) {
            SystemProperty systemProperty = (SystemProperty)i.next();
            SystemPropertyValue systemPropertyValue = new SystemPropertyValue();
            systemPropertyValue.setSystemPropertyId(systemProperty.getSystemPropertyId());
            systemPropertyValue.setName(systemProperty.getName());
            systemPropertyValue.setValue(systemProperty.getValue());
            systemPropertyValue.setIsPrivate(systemProperty.getIsPrivate());
            systemPropertyValue.setIsEditable(systemProperty.getIsEditable());
            propertyValues.add(systemPropertyValue);
        }
        return propertyValues;
    }
    
    public ArrayList getSystemPropertyList() {
        return m_systemPropertyList;
    }
    
    public void setSystemPropertyList(ArrayList systemPropertyList) {
        m_systemPropertyList = systemPropertyList;
    }
    
}
